package com.hjj.thread.t1;

public class MyThread1 extends Thread {
    private String name;
    private int count = 5;
    public MyThread1(String name) {
        this.name = name;
    }
    @Override
    public synchronized void run() {
        count--;
        System.out.println("由 " + this.currentThread().getName() + " 计算 count=" + count);
    }
    public static void main(String[] args) {
        MyThread1 myThread1 = new MyThread1("a");
        Thread a = new Thread(myThread1, "A");
        Thread b = new Thread(myThread1, "B");
        Thread c = new Thread(myThread1, "C");
        Thread d = new Thread(myThread1, "D");
        Thread e = new Thread(myThread1, "e");
        a.start();
        b.start();
        c.start();
        d.start();
        e.start();
    }
}
